# -*- coding: utf-8 -*-
"""
Created on Mon Sep 20 09:04:46 2021

@author: SIO2
"""
import random
def Mystere():
    #Debut fonction
    T=[0,0,0,0,0]
    for K in range(0,5):
        T[K]=random.randint(1,5)
    return T
    #Fin fonction
def Retour(T,Gain):
    #Debut fonction
    L=0
    for K in range(0,5):
        L=L+T[K]
    if L<=7:
        R=0
        Gain=Gain+1
    else:
        R=1
    return R,Gain
    #Fin fonction

def Apparition(T,Gain):
    #Debut fonction
    L=0
    for K in range(0,5):
        if T[K]==2:
            L=L+1
        else:
            L=L+0
    if L==3:
        Gain=Gain+5
    else:
        Gain=Gain+0
    return Gain

#Algorithme Principal
T=[0,0,0,0,0]
K=0
Gain=0
Partie=0
while Gain<=20:
    Mystere()
    Retour(T,Gain)
    Apparition(T,Gain)
    print(Gain)
    Partie=Partie+1
print("Nombre de parties=",Partie)
